package com.xiangban.controller;


import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
import com.github.binarywang.wxpay.bean.entpay.EntPayResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.xiangban.config.WxConfig;
import com.xiangban.model.res.ApiResult;

import com.xiangban.service.impl.PayServiceImpl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.bind.annotation.*;


import java.math.BigDecimal;
import java.util.HashMap;

@RestController
@RequestMapping("/pay")
@Slf4j
public class PayController {


    @Autowired
    private PayServiceImpl payService;

    @RequestMapping("/unifiedOrder")
    public ApiResult<Object> unifiedOrder (@RequestBody HashMap<String,String> map) throws Exception {//accessId    type =JSAPI  APP
        return ApiResult.newSuccess(payService.unifiedOrder(map));
    }

    /**
     * 提现接口
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/transfers")
    public ApiResult<Object> transfers (@RequestBody HashMap<String,String> map) throws Exception {//accessId    type =JSAPI  APP
        return payService.transfers(map);
    }

    /**
     * 退款接口
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping("/refund")
    public ApiResult<Object> refund (@RequestBody HashMap<String,String> map) throws Exception {//accessId    type =JSAPI  APP
        return ApiResult.newSuccess(payService.refund(map));
    }


}
